package world.criver.imagecompresstool.modular;

public class moRow {
    private String name;
    private long old_size;
    private byte active=0;//压缩中
    private long new_size=0;
    private float pro=0;
    private boolean replace=false;

    public moRow(String name, long old_size) {
        this.name=name;
        setOld_size(old_size);
    }

    public String getPro0(){
        return String.format("%.2f",pro*100)+"%";
    }
    public String getOldSize(){
        return formatSize(old_size);
    }
    public String getNewSize(){
        return formatSize(new_size);
    }
    private String formatSize(long size){
        double a=size;
        String q="B";
        if(a>1024){
            a/=1024;
            q="KB";
        }
        if(a>1024){
            a/=1024;
            q="MB";
        }
        if(a>1024){
            a/=1024;
            q="GB";
        }
        return String.format("%.2f%s",a,q);
    }

    public float getPro() {
        return pro;
    }

    public void setPro(float pro) {
        this.pro = pro;
    }

    public long getNew_size() {
        return new_size;
    }

    public void setNew_size(long new_size) {
        this.new_size = new_size;
        this.pro=(this.old_size-this.new_size)*1.0f/this.old_size;
    }

    public String getResult() {
        if(active==0)return "压缩中...";
        if(active==1)return "完成";
        return "失败";
    }

    public void setResult(String result) {
        result = result;
    }

    public long getOld_size() {
        return old_size;
    }

    public void setOld_size(long old_size) {
        this.old_size = old_size;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public byte getActive(){
        return active;
    }
    public void setActive(byte a){
        this.active=a;
    }
    public void addActive(){
        active++;
    }

    public boolean isReplace() {
        return replace;
    }

    public void setReplace(boolean replace) {
        this.replace = replace;
    }
}
